function throttle(fn, delay) {
    //上次触发节流函数时间
    let lastTime = 0;

    return function(...args) {
        const now = Date.now();

        if (now - lastTime >= delay) {
            fn.apply(this, args);
            lastTime = now;
        }
    };
    
}



const throttledHandleScroll = throttle(()=>{
    console.log('Scroll event');
}, 300);
  

// 在滚动时每隔300毫秒执行handleScroll函数
window.addEventListener('scroll', throttledHandleScroll);